package common;

import java.util.EnumMap;
import java.util.Random;

public class PlayerLimits extends EnumMap<Commodity,CommodityLimits> implements Sendable {

	private static final long serialVersionUID = 7315124049190122704L;

	// default1 == true => use a default construction.
	// default1 == false=> this object will be manually constructed.
	public PlayerLimits (boolean default1) {
		super(Commodity.class);
		if (default1) doDefault();
	}
	
	private void doDefault() {
		Random r = new Random();
		for (Commodity c : Commodity.values()) {
			boolean isBuyer = r.nextBoolean();
			int value = (isBuyer) ?  100 :  100;  
			CommodityLimits cr = new CommodityLimits(isBuyer,50,value);
			this.put(c,cr);
		}
	}
	
	
	//Determines if this player limits is complete.
	public boolean isComplete() {
		for (Commodity c : Commodity.values())
			if (!this.containsKey(c))
				return false;
		return true;
	}
	
	public String getType() {
		return "PlayerLimits";
	}

}
